//
//  QZMyVC.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/6/18.
//

#import "QZMyVC.h"
#import "GKPageScrollView.h"
#import "JXCategoryView.h"
#import "QZMyMessegeView.h"
#import "QZMyVideoVC.h"
#import "QZMyLikeVC.h"
#import "QZMyCollectionVC.h"
#import "My_editViewController.h"
#import "MyServerVC.h"
#import "SanyaViewController.h"
#import "QYLogViewController.h"
#import "QZMyFansVC.h"
#import "DJAttestationzVC.h"
#import "QZMyTitleView.h"
#import "MyShareListVC.h"

@interface QZMyVC ()<GKPageScrollViewDelegate,JXCategoryViewDelegate>
@property (nonatomic, strong) GKPageScrollView      *pageScrollView;

@property (nonatomic, strong) QZMyMessegeView        *headerView;

@property (nonatomic, strong) QZMyTitleView   *categoryView;

@property (nonatomic, strong) NSArray               *titles;
@property (nonatomic, strong) NSArray               *images;

@property (nonatomic, strong) UILabel               *titleView;

@property (nonatomic, strong) UIView                *navView;
@property (nonatomic, strong) UIButton              *infoEdit;
@property (nonatomic, strong) UIButton              *infoSetting;
@property (nonatomic, strong) UIView                *navMessegeView;
@property (nonatomic, strong) UIImageView           *navMessegeFace;
@property (nonatomic, strong) UILabel               *navMessegeNick;
@property (nonatomic, strong) UIView               *ding;
@property (nonatomic, assign) BOOL                isheaderSeleteImage;
@end

@implementation QZMyVC

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if(self.isheaderSeleteImage){
        self.isheaderSeleteImage = NO;
    }else{
        [self myMessegeRequest];
        [self.mm_drawerController setEnableGesture:YES];
    }
    if([[QZUserInfoModel share].feedbackTotal intValue] > 0){
        _ding.hidden = NO;
    }else{
        _ding.hidden = YES;
    }
}
- (void)publicVideo:(QZVideoModel *)data type:(QZDataUpdateType)type{
    [self myMessegeRequest];
}
-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
    
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = viewback_black;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:self.pageScrollView];
    [self.pageScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.view);
        make.bottom.mas_offset(-KTab_H);
    }];
    
    [self.pageScrollView reloadData];
    
    NSLog(@"%f==%f==%f==%f",KScreen_H,self.view.frame.size.height,KTab_H,KSafeAreaBottomHeight);
    
    _navView = [[UIView alloc]init];
    _navView.backgroundColor = [UIColor clearColor];
       UILabel * oldshowSSSSTip2 = [[UILabel alloc]init];
    oldshowSSSSTip2.clipsToBounds = YES;
    oldshowSSSSTip2.text = @"kass显示区";
    oldshowSSSSTip2.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip2.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip2.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip2.hidden = YES;
    [self.view addSubview:oldshowSSSSTip2];
    [self.view addSubview:_navView];
    
    _infoEdit = [[UIButton alloc]init];
    [_infoEdit setImage:KImageNamed(@"ico_my_nav_edit_nor") forState:UIControlStateNormal];
    [_infoEdit addTarget:self action:@selector(infoEditTap) forControlEvents:UIControlEventTouchUpInside];
    [_navView addSubview:_infoEdit];
    
    _infoSetting = [[UIButton alloc]init];
    [_infoSetting setImage:KImageNamed(@"ico_my_nav_setting_nor") forState:UIControlStateNormal];
    [_infoSetting addTarget:self action:@selector(infoSettingTap) forControlEvents:UIControlEventTouchUpInside];
    [_navView addSubview:_infoSetting];
    
    
    
    [_navView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_offset(0);
        make.height.mas_offset(KNav_H);
    }];
    
//    _navMessegeView = [[UIView alloc]init];
//    _navMessegeView.backgroundColor = [UIColor clearColor];
//       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:_navMessegeView];
    
    _navMessegeFace= [[UIImageView alloc]init];
    _navMessegeFace.contentMode = UIViewContentModeScaleAspectFill;
    _navMessegeFace.layer.cornerRadius = 17;
    _navMessegeFace.clipsToBounds = YES;
    _navMessegeFace.hidden = YES;
    [_navView addSubview:_navMessegeFace];
    
    _navMessegeNick = [[UILabel alloc]init];
    _navMessegeNick.textColor = [UIColor whiteColor];
    _navMessegeNick.font = FontBold(13);
    _navMessegeNick.hidden = YES;
    [_navView addSubview:_navMessegeNick];
    
    
    _ding = [[UIView alloc]init];
    _ding.backgroundColor = [UIColor redColor];
    _ding.layer.cornerRadius = 4;
    _ding.clipsToBounds = YES;
    [_navView addSubview:_ding];
    
    [_navView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_offset(0);
        make.height.mas_offset(KNav_H);
    }];
    
    [_infoSetting mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-5);
        make.right.mas_offset(-12);
        make.width.height.mas_offset(34);
    }];
    [_ding mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-34);
        make.right.mas_offset(-10);
        make.width.height.mas_offset(8);
    }];
    KWeakSelf
    [_infoEdit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-5);
        make.right.equalTo(weakSelf.infoSetting.mas_left).mas_offset(-10);
        make.width.height.mas_offset(34);
    }];
    
    [_navMessegeFace mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-5);
        make.left.mas_offset(15);
        make.width.height.mas_offset(34);
    }];
    
    [_navMessegeNick mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(-5);
        make.left.equalTo(weakSelf.navMessegeFace.mas_right).mas_offset(4);
        make.right.equalTo(weakSelf.infoEdit.mas_left).mas_offset(-10);
        make.width.height.mas_offset(34);
    }];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOut) name:@"acountlogin" object:nil];
    [SVProgressHUDTool showWithStatus:nil];
    [[QZDataUpdate share] addListenerObj:self];
}
- (void)loginOut{
    [self.pageScrollView reloadData];
}
- (void)myMessegeRequest{
    KMutableDic(sendDic)
    KWeakSelf
    [YBNetBase userhomeRequest:sendDic isMy:YES successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
        [SVProgressHUDTool dismiss];
        if(code == 200){
            [[NSUserDefaults standardUserDefaults]setObject:data forKey:QZUserInfoKey];
            [[QZUserInfoModel share] setValuesForKeysWithDictionary:data];
            [weakSelf.headerView refreshMessege];
            weakSelf.navMessegeNick.text = [QZUserInfoModel share].nickname;
            [weakSelf.navMessegeFace sd_setImageWithURL:KUrlString([QZUserInfoModel share].face) placeholderImage:weakSelf.navMessegeFace.image];
            
            if(weakSelf.titles == nil){
                if([[QZUserInfoModel share].collect_permission intValue] == 1 && [[QZUserInfoModel share].like_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(1),@(1)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else if([[QZUserInfoModel share].collect_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(1),@(0)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else if([[QZUserInfoModel share].like_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(0),@(1)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else{
                    weakSelf.images = @[@(0),@(0),@(0)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }
                weakSelf.categoryView.imgIndexArr = weakSelf.images;
                weakSelf.categoryView.titles = weakSelf.titles;
                [weakSelf.categoryView reloadData];
            }else{
                if([[QZUserInfoModel share].collect_permission intValue] == 1 && [[QZUserInfoModel share].like_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(1),@(1)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else if([[QZUserInfoModel share].collect_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(1),@(0)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else if([[QZUserInfoModel share].like_permission intValue] == 1){
                    weakSelf.images = @[@(0),@(0),@(1)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }else{
                    weakSelf.images = @[@(0),@(0),@(0)];
                    weakSelf.titles = @[[NSString stringWithFormat:@"作品 %@",[QZUserInfoModel share].video_total],[NSString stringWithFormat:@"收藏 %@",[QZUserInfoModel share].collect_num], [NSString stringWithFormat:@"喜欢 %@",[QZUserInfoModel share].like_num]];
                }
                weakSelf.categoryView.imgIndexArr = weakSelf.images;
                weakSelf.categoryView.titles = weakSelf.titles;
                [weakSelf.categoryView reloadDataWithoutListContainer];
            }
            [weakSelf setHeraderViewHeight];
        }else{
            [YBMsgPop showPop:msg];
        }
    }];
}
- (void)setHeraderViewHeight{
    CGFloat height = KNav_H+225;
    height = height+self.headerView.introHeight;
    self.headerView.frame = CGRectMake(0, 0, KScreen_W, height);
    [self.pageScrollView refreshHeaderView];
}
#pragma mark - GKPageTableViewGestureDelegate
- (BOOL)pageTableView:(GKPageTableView *)tableView gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    // 禁止UIScrollView左右滑动时，上下左右都可以滑动
    if(otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer||otherGestureRecognizer == self.categoryView.contentScrollView.panGestureRecognizer){
        return NO;
    }
    if([otherGestureRecognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]){
        return NO;
    }
    if (otherGestureRecognizer.view.tag == 60) {
        return NO;
    }
    return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
}
- (void)mainTableViewDidScroll:(UIScrollView *)scrollView isMainCanScroll:(BOOL)isMainCanScroll {
    CGFloat offsetY = scrollView.contentOffset.y;
    if(offsetY > KNav_H+20){
        if(_navMessegeFace.hidden){
            _navView.backgroundColor = viewback_black;
            _navMessegeFace.hidden = NO;
            _navMessegeNick.hidden = NO;
        }
    }else{
        if(_navMessegeFace.hidden == NO){
            _navView.backgroundColor = [UIColor clearColor];
            _navMessegeFace.hidden = YES;
            _navMessegeNick.hidden = YES;
        }
    }
    [self.headerView.background mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerView).mas_offset(offsetY);
    }];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    [self.pageScrollView horizonScrollViewWillBeginScroll];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [self.pageScrollView horizonScrollViewDidEndedScroll];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    [self.pageScrollView horizonScrollViewDidEndedScroll];
}
#pragma mark - GKPageScrollViewDelegate
- (BOOL)shouldLazyLoadListInPageScrollView:(GKPageScrollView *)pageScrollView {
    return YES;
}
- (UIView *)headerViewInPageScrollView:(GKPageScrollView *)pageScrollView {
    return self.headerView;
}

- (UIView *)segmentedViewInPageScrollView:(GKPageScrollView *)pageScrollView {
    return self.categoryView;
}

- (NSInteger)numberOfListsInPageScrollView:(GKPageScrollView *)pageScrollView {
    return self.titles.count;
}

- (id<GKPageListViewDelegate>)pageScrollView:(GKPageScrollView *)pageScrollView initListAtIndex:(NSInteger)index {
    if(index == 0){
        QZMyVideoVC *listVC = [[QZMyVideoVC alloc] init];
        listVC.headerHeigh = self.headerView.frame.size.height;
        return listVC;
    }else if (index == 1){
        QZMyCollectionVC *listVC = [[QZMyCollectionVC alloc] init];
        listVC.headerHeigh = self.headerView.frame.size.height;
        return listVC;
    }else{
        QZMyLikeVC *listVC = [[QZMyLikeVC alloc] init];
        listVC.headerHeigh = self.headerView.frame.size.height;
        return listVC;
    }
   
}
#pragma makr - 事件
- (void)infoEditTap{
    My_editViewController * edit = [[My_editViewController alloc]init];
    [self.navigationController pushViewController:edit animated:YES];
}
- (void)infoSettingTap{
    MyServerVC * edit = [[MyServerVC alloc]init];
    [self.navigationController pushViewController:edit animated:YES];
}

#pragma mark - 懒加载
- (GKPageScrollView *)pageScrollView {
    if (!_pageScrollView) {
        _pageScrollView = [[GKPageScrollView alloc] initWithDelegate:self];
        _pageScrollView.backgroundColor = [UIColor clearColor];
        _pageScrollView.mainTableView.backgroundColor = [UIColor clearColor];
        _pageScrollView.listContainerView.backgroundColor = viewback_black;
//        _pageScrollView.listContainerType = GKPageListContainerType_ScrollView;
        _pageScrollView.lazyLoadList = YES;
        _pageScrollView.ceilPointHeight = KNav_H;
    }
    return _pageScrollView;
}

- (QZMyMessegeView *)headerView {
    if (!_headerView) {
        _headerView = [[QZMyMessegeView alloc] initWithFrame:CGRectMake(0, 0, KScreen_W, KNav_H+245)];
        KWeakSelf
        _headerView.myMessegeHeaderBlock = ^(NSInteger index) {
            if(index == 0){
                //展开收起
                [weakSelf.headerView refreshMessege];
                [weakSelf setHeraderViewHeight];
            }else if (index == 1){
                [YBMsgPop showPop:[NSString stringWithFormat:@"收到%@赞",[Tools NumberToShowString:[[QZUserInfoModel share].total_like integerValue]]]];
            }else if (index == 2){
                QZMyFansVC * vc = [[QZMyFansVC alloc]init];
                vc.listType = 0;
                [weakSelf.navigationController pushViewController:vc animated:YES];
            }else if (index == 3){
                QZMyFansVC * vc = [[QZMyFansVC alloc]init];
                vc.listType = 1;
                [weakSelf.navigationController pushViewController:vc animated:YES];
            }else if (index == 4){
                MyShareListVC * vc = [[MyShareListVC alloc]init];
                [weakSelf.navigationController pushViewController:vc animated:YES];
            }else if (index == 5){
                [weakSelf infoEditTap];
            }else if (index == 6){
                //创作者认证
                DJAttestationzVC * about = [DJAttestationzVC new];
                [weakSelf.navigationController pushViewController:about animated:YES];
            }else if (index == 7){
                [weakSelf changeBackTap];
            }else if (index == 8){
                [weakSelf changeFaceTap];
            }
        };
    }
    return _headerView;
}

- (QZMyTitleView *)categoryView {
    if (!_categoryView) {
        _categoryView = [[QZMyTitleView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40.0f)];
        _categoryView.backgroundColor = viewback_black;
        _categoryView.imgName_nor = @"ico_title_lock_full_nor";
        _categoryView.imgName_sel = @"ico_title_lock_full_sel";
        _categoryView.imgIndexArr = @[@(0),@(0),@(0)];
        _categoryView.titles = self.titles;
        _categoryView.delegate = self;
        _categoryView.titleColor = ColorHex(@"A3A5A6");
        _categoryView.titleSelectedColor = [UIColor whiteColor];
        _categoryView.titleFont = [UIFont systemFontOfSize:16.0f];
        _categoryView.titleSelectedFont = [UIFont systemFontOfSize:16.0f];
        
        JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
        lineView.indicatorColor = [UIColor whiteColor];
        lineView.indicatorWidth = 30.0f;
        lineView.indicatorCornerRadius = 0;
        lineView.lineStyle = JXCategoryIndicatorLineStyle_Normal;
        lineView.verticalMargin = 5;
        _categoryView.indicators = @[lineView];
        _categoryView.defaultSelectedIndex = 0;
        
        _categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pageScrollView.listContainerView;
        
        // 添加分割线
//        UIView *btmLineView = [UIView new];
//        btmLineView.backgroundColor = COLOR_ALPH(255, 255, 255, 0.5);
//        [_categoryView addSubview:btmLineView];
        
//        [btmLineView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.bottom.equalTo(self->_categoryView);
//            make.height.mas_equalTo(0.5);
//        }];
    }
    return _categoryView;
}

- (UILabel *)titleView {
    if (!_titleView) {
        _titleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
        _titleView.font = [UIFont systemFontOfSize:18.0f];
        _titleView.textColor = [UIColor whiteColor];
        _titleView.text = @"❤️会说话的刘二豆❤️";
        _titleView.alpha = 0;
    }
    return _titleView;
}
- (void)changeFaceTap{
    TZImagePickerController *imagePickerVc=[[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:nil];
    [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
        [leftButton setImage:[UIImage imageNamed:@"back_wite"] forState:UIControlStateNormal];
        [leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
    }];
    imagePickerVc.allowTakePicture = YES;
    imagePickerVc.allowTakeVideo = NO;
    imagePickerVc.showSelectBtn = NO;
    imagePickerVc.needCircleCrop = YES;
    imagePickerVc.scaleAspectFillCrop = YES;
    imagePickerVc.circleCropRadius = KScreen_W/2;
    imagePickerVc.allowPickingOriginalPhoto = NO;
    imagePickerVc.allowPickingVideo = NO;
    imagePickerVc.statusBarStyle = UIStatusBarStyleDefault;
    imagePickerVc.needShowStatusBar = YES;
    imagePickerVc.navigationBar.translucent = NO;
    imagePickerVc.iconThemeColor = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.naviBgColor = [UIColor whiteColor];
    imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
    imagePickerVc.barItemTextColor = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.oKButtonTitleColorNormal = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.naviTitleColor = [UIColor blackColor];
    imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
    KWeakSelf
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        if(!photos.count){
            return;
        }
        
        [weakSelf changeFaceOrBackImage:photos[0] isFace:YES];
    }];
    [self presentViewController:imagePickerVc animated:YES completion:nil];
    weakSelf.isheaderSeleteImage = YES;
}
- (void)changeBackTap{
    TZImagePickerController *imagePickerVc=[[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:nil];
    [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
        [leftButton setImage:[UIImage imageNamed:@"back_wite"] forState:UIControlStateNormal];
        [leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
    }];
    imagePickerVc.allowTakePicture = YES;
    imagePickerVc.allowTakeVideo = NO;
    imagePickerVc.showSelectBtn = NO;
    imagePickerVc.needCircleCrop = YES;
    imagePickerVc.scaleAspectFillCrop = YES;
    imagePickerVc.circleCropRadius = KScreen_W/2;
    imagePickerVc.allowPickingOriginalPhoto = NO;
    imagePickerVc.allowPickingVideo = NO;
    imagePickerVc.statusBarStyle = UIStatusBarStyleDefault;
    imagePickerVc.needShowStatusBar = YES;
    imagePickerVc.navigationBar.translucent = NO;
    imagePickerVc.iconThemeColor = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.naviBgColor = [UIColor whiteColor];
    imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
    imagePickerVc.barItemTextColor = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.oKButtonTitleColorNormal = [UIColor colorWithHexString:@"#007AFF"];
    imagePickerVc.naviTitleColor = [UIColor blackColor];
    imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
    KWeakSelf
    [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        if(!photos.count){
            return;
        }
        
        [weakSelf changeFaceOrBackImage:photos[0] isFace:NO];
    }];
    [self presentViewController:imagePickerVc animated:YES completion:nil];
    weakSelf.isheaderSeleteImage = YES;
}
- (void)changeFaceOrBackImage:(UIImage *)image isFace:(BOOL)isface{
    if(!image){
        return;
    }
    
    [SVProgressHUDTool showWithStatus:nil];
    KMutableDic(sendDic)
    KWeakSelf
    if(isface){
        weakSelf.headerView.face.image = image;
        [sendDic setObject:@"face" forKey:@"key"];
        NSData *imageData = UIImageJPEGRepresentation(image, 0.7);
        [YBNetBase userEditFaceRequest:sendDic fileData:imageData successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
            [SVProgressHUDTool dismiss];
            if(code == 200){
                [[NSUserDefaults standardUserDefaults]setObject:data forKey:QZUserInfoKey];
                /** 给用户单例赋值 */
                [[QZUserInfoModel share] setValuesForKeysWithDictionary:data];
                [[NSUserDefaults standardUserDefaults] synchronize];
                [weakSelf.headerView refreshMessege];
//                [self->my_editview.my_edit_tableView reloadData];
            }else{
                [YBMsgPop showPop:msg];
            }
        }];
    }else{
        weakSelf.headerView.background.image = image;
        [sendDic setObject:@"back_image" forKey:@"key"];
        NSData *imageData = UIImageJPEGRepresentation(image, 0.7);
        [YBNetBase userEditbackgroudRequest:sendDic fileData:imageData  successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
            [SVProgressHUDTool dismiss];
            if(code == 200){
                [[NSUserDefaults standardUserDefaults]setObject:data forKey:QZUserInfoKey];
                /** 给用户单例赋值 */
                [[QZUserInfoModel share] setValuesForKeysWithDictionary:data];
                [[NSUserDefaults standardUserDefaults] synchronize];
            }else{
                [YBMsgPop showPop:msg];
            }
        }];
    }
}
@end
